package workQueue;

import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author： pang-yun
 * @date： 2021-12-14 17:03
 * 功能目的 ：用于
 */

public class Work2 {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("127.0.0.1");
        connectionFactory.setUsername("pangyun");
        connectionFactory.setPassword("1234");

        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println(new String(message.getBody()));
        };
        CancelCallback cancelCallback = (message) -> {
            System.out.println("failed");
        };

        channel.basicConsume("hello", true, deliverCallback, cancelCallback);
    }
}
